package com.ftg.learn.controller;

import dev.langchain4j.community.model.dashscope.WanxImageModel;
import dev.langchain4j.data.image.Image;
import dev.langchain4j.model.output.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/img")
public class TextToImageController {


    @Autowired
    private WanxImageModel wanxImageModel;

    @GetMapping("/generate")
    public String generate(@RequestParam("prompt") String prompt) {
        Response<Image> response = wanxImageModel.generate(prompt);
        return response.content().url().toString();
    }

}